package com.du.limiting.sentinel.component;

import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author dujunguang
 */
@Component
public class OriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest request) {
//        RequestWrapper requestWrapper = new RequestWrapper(request);
//        String body = requestWrapper.getBody();
//        JSONObject jsonObject = JSONObject.parseObject(body);
//        String name = jsonObject.getString("name");
//        System.out.println(name);
//        return name;

        String name = request.getParameter("name");
        System.out.println(name);
        return name;
    }
}